package com.ldy.transactional;

import org.springframework.jdbc.core.support.JdbcDaoSupport;

/**
 * 学生DAO类<br>
 * 版权: Copyright (c) 2011-2018<br>
 * 公司: 活力天汇<br>
 *
 * @author: 刘德咏<br>
 * @date: 2018-07-23<br>
 */
public class StudentDao extends JdbcDaoSupport {

    public boolean save(StudentEntity studentEntity) {
        String sql = "INSERT INTO stu(name, age) VALUES (?, ?)";
        int update = getJdbcTemplate().update(sql, new Object[]{studentEntity.getName(), studentEntity.getAge()});
        return update == 1;
    }

    public boolean delete(int id) {
        String sql = "DELETE FROM stu WHERE id = ?";
        return 1 == getJdbcTemplate().update(sql, id);
    }

}
